const express = require("express");
const router = express.Router();
const userService = require("./service/UserServiceImpl");

// 新增修改用户
router.post("/saveOrUpdate", (req, res, next) => {
  userService.saveOrUpdateUser(req, res, next);
});

// 删除用户
router.post("/delete", (req, res, next) => {
  userService.deleteUserById(req, res, next);
});

// 获取当前用户详情信息
router.get("/getUserInfoByAuth", (req, res, next) => {
  userService.getUserInfoByAuth(req, res, next);
});

// 通过id获取用户详情信息
router.post("/getUserInfo", (req, res, next) => {
  userService.getUserInfo(req, res, next);
});

// 获取当前用户的菜单权限
router.get("/getUserAuth", (req, res, next) => {
  userService.getUserMenuAuth(req, res, next);
});

// 查询用户列表(全量)
router.post("/list", (req, res, next) => {
  userService.getUserList(req, res, next);
});

// 查询用户列表(分页)
router.post("/page", (req, res, next) => {
  userService.getUserPage(req, res, next);
});

// 重置密码(需要管理员权限)
router.post("/resetPassword", (req, res, next) => {
  userService.resetPassword(req, res, next);
});

// 修改密码
router.post("/changePassword", (req, res, next) => {
  userService.changePassword(req, res, next);
});

module.exports = router;
